package com.sc.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CrossIntercoptor implements WebMvcConfigurer {
    public void addCorsMappings(CorsRegistry registry){
        System.out.println("跨域");
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowCredentials(true)
                .allowedMethods("POST","GET","PUT","OPTIONS")
                .allowedHeaders("*")
                .maxAge(5000);
    }
}
